<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<button>发送请求</button>
</body>

<script>
	const btn = document.querySelector("button");
	btn.onclick = function(){
		const fnName = "zhang"+Math.random().toString(36).slice(2)+Date.now();
		window[fnName]=function(obj){
			console.log(obj);
		}
		const script = document.createElement("script");
		script.src = "http://zhangpeiyue.com/sum?cb="+fnName+"&a=1&b=2";
		script.onload = function(){
			// 当script请求完毕之后执行
			delete window[fnName];
			document.body.removeChild(script);
		}
		document.body.appendChild(script);
	}

</script>
</html>